<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改器材类型')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-type-edit" th:object="${entityDeviceType}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">器材类型名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" autocomplete="off" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">顺序：</label>
                <div class="col-sm-8">
                    <input name="sequence" th:field="*{sequence}" class="form-control" type="number"  autocomplete="off" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">有效性：</label>
                <div class="col-sm-8">
                    <select class="form-control" th:field="*{valid}" name="">
                        <option value="1">有效</option>
                        <option value="0">无效</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/type";
        var icon = "<i class='fa fa-times-circle'></i>";
        $("#form-type-edit").validate({
            focusCleanup: true,
            rules: {
                name: {
                    required: true,
                    remote: {
                        url: "/system/type/checkName",     //后台处理程序
                        type: "post",               //数据发送方式
                        dataType: "json",           //接受数据格式
                        data: {                     //要传递的数据
                            name: function () {
                                return $("#name").val();
                            }, id: function () {
                                return $("#id").val();
                            }
                        }
                    }
                }
            },
            messages: {
                name: {
                    required: icon + "请输入器材类型名称",
                    remote: icon + "该器材类型名称已经存在"
                }
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-type-edit').serialize());
            }
        }
    </script>
</body>
</html>